<template>
  <div class="right">
    <div class="right-describ">布局样式</div>
    <div class="right-choices">
      <div
        class="right-choices-one"
        @click="isPorps = true"
        :class="{ actived: isPorps }"
      >
        属性
      </div>
      <div
        class="right-choices-two"
        @click="isPorps = false"
        :class="{ actived: !isPorps }"
      >
        样式
      </div>
    </div>
    <div class="right-main" v-if="Object.keys(selectComData).length > 0">
      <div v-if="isPorps">
        <component
          :views="selectComData"
          :is="comProps[selectComData.comName]"
        ></component>
      </div>
      <div v-else>
        <component
          :views="selectComData"
          :is="comStyle[selectComData.comName]"
        ></component>
      </div>
    </div>
    <div class="right-main right-text" v-else>
      <div class="right-main-promot">您还未选中任何组件</div>
    </div>
  </div>
</template>

<script setup>
import { computed, ref } from "vue";
import { useStore } from "vuex";

const store = useStore();
const selectComData = computed(() => store.state.currentCom);

const isPorps = ref(true);
const comProps = {
  BtnCom: "BtnProps",
  ImageCom: "ImageProps",
  LinkCom: "LinkProps",
  VideoCom: "VideoProps",
  TextCom: "TextProps",
  FlexBox: "FlexBoxProps",
};
const comStyle = {
  BtnCom: "BtnStyle",
  ImageCom: "ImageStyle",
  LinkCom: "LinkStyle",
  VideoCom: "VideoStyle",
  TextCom: "TextStyle",
  FlexBox: "FlexBoxStyle",
};
// export default {
//   name: "RightCom",
//   data() {
//     return {
//       isMeta: true,
//       views: {},
//       comProps: {
//         BtnCom: "BtnProps",
//         ImageCom: "ImageProps",
//         LinkCom: "LinkProps",
//         VideoCom: "VideoProps",
//         TextCom: "TextProps",
//         FlexBox: "FlexBoxProps",
//       },
//       comStyle: {
//         BtnCom: "BtnStyle",
//         ImageCom: "ImageStyle",
//         LinkCom: "LinkStyle",
//         VideoCom: "VideoStyle",
//         TextCom: "TextStyle",
//         FlexBox: "FlexBoxStyle",
//       },
//     };
//   },
//   methods: {},
//   mounted() {
//     this.$bus.on("sendViews", (v) => {
//       this.views = v;
//     });
//     this.$bus.on("cleanViews", () => {
//       this.views = {};
//     });
//   },
// };
</script>

<style lang="scss">
@import "@/assets/css/rightModule.scss";

.right-main::-webkit-scrollbar {
  display: none;
}

.right {
  width: 300px;
  height: 100%;
  background: #fff;
  padding: 3px 10px 0px 10px;
  margin-left: 2px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  align-items: flex-start;
  justify-content: flex-start;
  box-sizing: border-box;
  -o-user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -khtml-user-select: none;
  user-select: none;
  z-index: 99;

  &-describ {
    height: 25px;
    display: flex;
    justify-content: flex-start;
    font-size: 12px;
    color: #aaa;
    align-items: center;
  }

  &-main {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;

    &-promot {
      color: #555;
      font-size: 12px;
      margin: 100px auto 0px;
    }
  }

  &-text {
    width: 100%;
  }

  &-describ img {
    width: 15px;
    height: 15px;
    margin-right: 5px;
    flex-shrink: 0;
  }

  &-choices {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    width: 100%;
    color: #888;
    font-size: 14px;
    flex-shrink: 0;

    &-one {
      width: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100%;
      border-bottom: 2px solid transparent;
    }

    &-two {
      width: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100%;
      border-bottom: 2px solid transparent;
    }
  }
}

.actived {
  color: rgb(85, 132, 255);
  border-bottom: 2px solid rgb(85, 132, 255);
  box-shadow: 0 0 3px #eee;
}
</style>
